<?php
	
	include("config.php");
    include(INCLUDEDIR."core.php");
	include("acceso.php");
	
	$id_categoria = isset($_GET['c'])?intval($_GET['c']):0;
	
	db::Connect();
	
	$tpl = new TemplatePower(TPLDIR."tpl.selector.html");
	
	$tpl->prepare();
	
	$tpl->newBlock("SELECTOR");
	
	$tpl->assign("mapacategoria",MapaCategoria($id_categoria,true,"selector_categorias.php?c="));

	$micategoria = db::GetRow("SELECT * FROM categorias WHERE id_categoria = '$id_categoria'");
	
	$query = "SELECT * FROM categorias WHERE id_categoria_padre = '$id_categoria'";
	$result = mysql_query($query);
	if($result && mysql_num_rows($result)>0) {		
		while($fila = mysql_fetch_assoc($result)) {
			$tpl->newBlock("SELECTORITEM");
			foreach($fila as $k => $v) $tpl->assign($k,$v);
		}		
		$tpl->assign("self",$_SERVER['PHP_SELF']);
	}
	
	$nivel = NivelCategoria($id_categoria);
	if($nivel>1) {
		$tpl->newBlock("ACTUAL");
		foreach($micategoria as $k => $v) $tpl->assign($k,$v);
	}
	$tpl->newBlock("CANCELAR");
	$tpl->printToScreen();
?>